package com.jhgsys.internal.common.enums;


import com.jhgsys.internal.dict.entity.DictItem;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

@Getter
public enum TenantBusTypeEnum {


    PROJECT_MAIN("project_main", "重大专项专项办"),
    PROJECT_SUB_LEAD("project_sub_lead", "重大专项子工程牵头单位"),
    PROJECT_ISSUE_LEAD("project_issue_lead", "重大专项课题牵头单位"),
    PROJECT_ISSUE_PARTICIPATE("project_issue_participate", "重大专项课题参研单位"),
    TASK_MAIN("task_main", "重大任务专项办"),
    TASK_LEAD("task_lead", "重大任务牵头单位"),
    GROUP_COMPLANY("group_complany","集团"),
    ;

    private final String code;
    private final String desc;

    TenantBusTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static List<DictItem> dictItemList() {
        List<DictItem> data = new ArrayList<>();
        for (TenantBusTypeEnum e : TenantBusTypeEnum.values()) {
            DictItem item = new DictItem();
            item.setItemCode(e.code);
            item.setItemName(e.getDesc());
            data.add(item);
        }
        return data;
    }


    public static TenantBusTypeEnum getInstance(String code) {
        for (TenantBusTypeEnum e : TenantBusTypeEnum.values()) {
            if (e.getCode().equals(code)) {
                return e;
            }
        }
        return null;
    }
}
